﻿using System;
using NBus.Practice.GreetingMessage;
using NServiceBus;

namespace NBus.Practice.GreetingReceiver
{
    public class GreetingHandler:IHandleMessages<GreetingCommand>
    {
        private readonly IBus _bus;

        public GreetingHandler(IBus bus)
        {
            _bus = bus;
        }

        public void Handle(GreetingCommand message)
        {
            Console.WriteLine("Received greetingCommand:{0}, times:{1}, Hello world",message.Id,message.Times);

            _bus.Publish(new GreetingEvent(){Id = message.Id,Times = message.Times});
        }
    }
}